package com.servlet.yanglaoyuan.service.impl;

import com.servlet.yanglaoyuan.pojo.User;
import com.servlet.yanglaoyuan.service.userService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.servlet.yanglaoyuan.mapper.userMapper;
@Service
public class userServiceImpl implements userService {
    @Autowired
    private userMapper userMapper;
    //绑定用户给老人
    @Override
    public void bindElderly(Long userId, Long elderlyId) {
        userMapper.bindElderly(userId,elderlyId);
    }

    //添加用户
    @Override
    public void addUser(User user) {
        userMapper.add(user);
    }
    //删除用户
    @Override
    public void deleteUser(Long id) {
        userMapper.deleteUser(id);
    }

    //更新用户
    @Override
    public void updateUser(User user) {
        System.out.println(user);
        userMapper.updateUser(user);
    }

    //根据用户名密码查询用户
    @Override
    public User findByNameAndPassword(String username, String password) {
        return userMapper.findByNameAndPassword(username,password);
    }
    //根据id查询用户
    @Override
    public User findById(Long id) {
        return userMapper.findById(id);
    }
}
